// JavaScript Document
function ShowHideArea(id){
	// Muc dich: Thay doi class tieu de + an/hien phan noi dung.
	
	t_id = id; // ID cua phan tieu de.
	c_id = id.replace('t-',''); // ID cua phan noi dung.
	
	//convert to element:
	t_id = document.getElementById(t_id);
	c_id = document.getElementById(c_id);
	
	if ($(t_id).attr("className")=="title-hide") {	//Neu tieu de dang dong:
				$(t_id).removeClass();
				$(t_id).addClass("title-expand");	// thi mo tieu de.
			}
		else{										// Nguoc lai:
				$(t_id).removeClass();
				$(t_id).addClass("title-hide");		// thi dong tieu de.
	}
	
	// An hien phan noi dung tu dong:
	$(c_id).toggle();
}


// Toggle Element Visibility via JavaScript
function toggle(id) {
	if (document.getElementById(id).style.display == 'none') {
		document.getElementById(id).style.display = '';
	} else {
		document.getElementById(id).style.display = 'none';
	}
}

//Change class name: 
function ChangeClass(sid,sclassname) { 
   document.getElementById(sid).className = sclassname; 
} 

//Auto resize image:
function resizeImage(img,nsize,nborder,npadding,ccolor)
	{
		//var img = document.getElementById(id);		
		var nWidth=img.width;
		var	nHeight=img.height;	
		var nTotalPadBor;
		nTotalPadBor = 2*(nborder + npadding);
		nScale = nWidth/nHeight;		
		//Check:
		if (nScale > 1) {
			nWidth = nsize - nTotalPadBor;		
			nHeight = (nWidth*img.height)/img.width;
			//fix vertical-align:	
			nPaddingFix = (nWidth - nHeight)/2 + npadding;
			//Set style to image:
			img.width = nWidth;
			img.height = nHeight;
			img.style.padding = nPaddingFix + 'px ' + npadding + 'px';
			}
		else {
			//Return size:
			nHeight = nsize - nTotalPadBor;
			nWidth = (nHeight*img.width)/img.height;
			//fix align:	
			nPaddingFix = (nHeight - nWidth)/2 + npadding;	
			//Set style to image:	
			img.width = nWidth;
			img.height = nHeight;
			img.style.padding = npadding + 'px ' + nPaddingFix + 'px';
		}	
		//alert('nPaddingFix=' + nPaddingFix);
		img.style.border = nborder + 'px solid ' + ccolor;
		//img.style.padding = npadding + 'px';
	}
	
    //Change class name: 
    function ChangeClass(sid,sclassname) { 
       document.getElementById(sid).className = sclassname; 
    } 
    function expand(sid,fid) { 
       document.getElementById(sid).style.display = 'none'; 
       document.getElementById(fid).style.display = 'block'; 
    }
    function moreMenu(sid) { 
      if(document.getElementById(sid).style.display == 'block')
       {
            document.getElementById(sid).style.display = 'none';   
        } else{document.getElementById(sid).style.display = 'block';}
    }
